<template>
  <div class="collect">
    <returnPage></returnPage>
    <van-card
      v-for="(item, index) in cartList"
      :key="item.id"
      :price="item.retailPrice"
      :title="item.name"
      :thumb="item.picUrl"
      :desc="item.brief"
    >
      <template #footer>
        <van-button size="mini" @click="remo(index)">删除</van-button>
      </template>
    </van-card>
    <van-divider>没有更多了</van-divider>
  </div>
</template>

<script>
import request from '../../utils/request'
export default {
  name: 'collect',
  components: {},
  data () {
    return {
      cartList: []
    }
  },
  // 计算属性
  computed: {},
  watch: {},
  mounted () {
    request('collect/list', { params: { type: '0', page: '1', limit: '10' } }).then(
      (res) => {
        const { data } = res.data
        this.cartList = data.list
        // console.log(this.cartList)
      }
    )
  },
  methods: {
    remo (index) {
      request
        .post('collect/addordelete', {
          valueId: this.cartList[index].valueId,
          type: 0
        })
        .then((res) => {
          // console.log(res)
        })
      // console.log(index)
      this.cartList.splice(index, 1)
    }
  }
}
</script>

<style lang="scss" scoped></style>
